from GUI.Window.Editor.Confirm.loader import ConfirmEditor


stack = []  # 窗体栈表
Window = None
EditorPanel = None  # 工具面板


def init(window):
    global Window
    global EditorPanel
    Window = window
    EditorPanel = window.editorPanel  # 工具面板


def newEditor():
    if len(stack) > 0:
        stack[-1].hide()
    new = ConfirmEditor(EditorPanel)
    new.show()
    stack.append(new)
    return new


def delEditor(editorWidget):
    if editorWidget == stack[-1]:
        stack.remove(editorWidget)
        if len(stack) > 0:
            stack[-1].show()
    else:
        stack.remove(editorWidget)
    editorWidget.deleteLater()
    del editorWidget
